{# One document in the drawer: what it is, its pages as extraction stored them (a page opens its preview), the edit form, and its tags. Read pages hands it to the worker; the pages fill in on the next open. #} {% from "components/macros/layout.html" import card, dialog_title, facts %} {% from "components/macros/form.html" import action, field, text_input, textarea, date_input, primary_button, select %}
{{ dialog_title(document.title, facts=[document.kind, details[2][1], (document.page_count or 0) ~ " pages"]|join(" . ")) }}
{{ action("Read pages", 'hx-post="' ~ urls.read ~ '" hx-swap="none" data-api-done="Reading started"', "primary") }} Download {{ action("Delete", hx_dialog(urls.delete), "danger") }}
{% for p in pages %} {% else %}

Not read yet. Read pages hands it to the worker.

{% endfor %}
{% call card("Details", id="document-facts") %}{{ facts(details) }}{% endcall %} {% call card("Edit") %}
{% call field("Title") %}{{ text_input("title", document.title, required=True) }}{% endcall %}
{% call field("Kind") %}{{ select("kind", kind_options, document.kind, blank=None, block=True) }}{% endcall %} {% call field("Dated") %}{{ date_input("document_date", document.document_date, block=True) }}{% endcall %}
{% call field("Note") %}{{ textarea("note", document.note or "", rows=3) }}{% endcall %} {{ primary_button("Save", type="submit") }}
{% endcall %} {% call card("Tags", id="document-tags") %}
{% for label in tags %} {{ label }} {% endfor %}
{% endcall %}